const MyPromise = require("../template")
/**  一、 基本状态流转测试 */

// 测试 Promise 状态从 pending 变为 fulfilled
function testFulfilled() {
  const promise = new MyPromise((resolve, reject) => {
    resolve(42)
  })

  promise.then(
    (value) => console.log("0, Fufilled:", value === 42), // 应打印 true
    (reason) => console.log("0, Rejected:", false)
  )
}
// 测试 Promise 状态从 pending 变为 rejected
function testRejected() {
  const promise = new MyPromise((resolve, reject) => {
    reject(new Error("Oops"))
  })

  promise.then(
    (value) => console.log("1, Fufilled:", false),
    (reason) => console.log("1, Rejected:", reason.message === "Oops") // // 应打印 true
  )
}

testFulfilled()
testRejected()
